/**  
 * @date 2023-12-05 
 * @author Zhang Yu
 */
package com.springboot.template.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisServer;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.template.service.MyService;
import com.springboot.template.service.RedisService;

/**  
 * @description: TODO
 */
@RestController
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class LoginController {
	
	@Autowired
	RedisService redisService;
	
	@GetMapping("/login")
	public String login(String username) {
		return "{\"token\":\"" + redisService.setToken(username) + "\"}";
	}
	
	@GetMapping("/token")
	public String checkToken(String username) {
		return "{\"token\":\"" + redisService.getToken(username) + "\"}";
	}

}
